package com.powervision.wechatcomposedemo

import WeComposeTheme
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Box
import com.powervision.wechatcomposedemo.model.WeChatViewModel
import com.powervision.wechatcomposedemo.ui.theme.ChatPage
import com.powervision.wechatcomposedemo.ui.theme.Home

class MainActivity : ComponentActivity() {
    private val viewModel: WeChatViewModel by viewModels()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            WeComposeTheme() {
                // A surface container using the 'background' color from the theme
                Box{
                    Home(viewModel)
                    ChatPage()
                }
            }
        }
    }

    override fun onBackPressed() {
        if (!viewModel.endChat()) {
            super.onBackPressed()
        }
    }
}


